1
開発者向け大規模言語モデルプロンプトの基礎
AI010Lesson 1
00:00

指示微調整モデルへの移行

基礎とは何か?

過去には、ベースとなる大規模言語モデル(LLM)は、膨大なデータに基づいて次の単語を予測するように訓練されてきました。しかし開発者にとっての真の力は、指示微調整モデル(Instruction Tuned LLMs)にあります。これらのモデルは、人間からのフィードバックによる強化学習(RLHF)を使って特定の命令に従い、役立つアシスタントとして動作するように改良されています。

黄金法則:LLMを知的だが機械的なインターンのように扱いましょう。そのモデルはあなたの具体的な文脈を持っていないため、目標について明確に伝える必要があります。

基本原則の適用方法

  1. 明確さと具体性 明確さは短さを意味しません。より多くの文脈を提供し、区切り記号(三重バックティックやXMLタグなど)を使用することで、モデルが指示と処理対象のデータを区別しやすくなります。
  2. モデルに考える時間を与える: 複雑なタスクには、思考の連鎖が必要です。モデルに結論にすぐ飛び込むように頼むと、推論エラーを起こす可能性が高くなります。まず自分自身で解決策を導き出すように指示しましょう。
幻覚を避ける
モデルは「説得力のある」が偽の情報を生成する可能性があります。常に事実を確認するか、モデルに出典を明示するように指示して、このリスクを軽減してください。
main.py
TERMINALbash — 80x24
> Ready. Click "Run" to execute.
>
Question 1
Why should a developer prefer an Instruction Tuned LLM over a Base LLM for building an application?
Base LLMs are better at following complex instructions.
Instruction Tuned LLMs are trained to follow tasks and are less likely to simply "complete" the text.
Base LLMs never hallucinate.
Challenge: Generating Structured Data
Apply prompting principles to format output.
You have a list of ingredients. You need to convert this list into a JSON format for a web app.
Task
Write a prompt that requests JSON output with keys for 'item' and 'quantity'. Include a condition check: If the input is not a recipe, output "No recipe detected."
Solution:
prompt = "You will be provided with text. If it contains a recipe, convert it to JSON with keys 'item' and 'quantity'. If not, write 'No recipe detected.' Text: <user_input>"